var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

function resolve (dir) {
	return path.join(__dirname, '..', dir)
}

module.exports = {
	entry: {
		entry: './src/entry.js',
	},
	output: {
		filename: '[name].js',
		path: path.resolve(__dirname, '../dist'),
		pathinfo: true
	},
	resolve: {
		extensions: ['.js', '.json'],
		alias: {
			'@': resolve('src')
		}
	},
	module: {
		rules: [{
			test: /\.css$/,
			use: ['to-string-loader', 'css-loader']
		}, {
			test: /\.(jpg|png|gif)$/,
			use: 'file-loader'
		}, {
			test: /\.(woff|woff2|eot|ttf|svg)$/,
			use: {
				loader: 'url-loader',
				options: {
					limit: 100000
				}
			}
		},
		{
			test: /\.(js)$/,
			use: 'babel-loader',
			exclude: /(node_modules)/
		}]
	},
	plugins: [
		new HtmlWebpackPlugin({
			filename: 'index.html',
			template: './public/index.html',
			inject: true,
			chunksSortMode: 'dependency'
		}),
		new webpack.HotModuleReplacementPlugin()
		/*
		new webpack.NamedModulesPlugin()
		*/
	]
};

